<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <!-- 避免IE使用兼容模式 -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="renderer" content="webkit">
    <!-- TopJUI框架样式 -->
    <link type="text/css" href="/static/topjui/themes/default/topjui.core.min.css" rel="stylesheet">
    <link type="text/css" href="/static/topjui/themes/default/topjui.blue.css" rel="stylesheet" id="dynamicTheme"/>
    <!-- FontAwesome字体图标 -->
    <link type="text/css" href="/static/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet"/>
    <!-- layui框架样式 -->
    <link type="text/css" href="/static/plugins/layui/css/layui.css" rel="stylesheet"/>
    <!-- jQuery相关引用 -->
    <script type="text/javascript" src="/static/plugins/jquery/jquery.min.js"></script>
    <script type="text/javascript" src="/static/plugins/jquery/jquery.cookie.js"></script>
    <!-- TopJUI框架配置 -->
    <script type="text/javascript" src="/static/public/js/topjui.config.js"></script>
    <!-- TopJUI框架核心-->
    <script type="text/javascript" src="/static/topjui/js/topjui.core.min.js"></script>
    <!-- TopJUI中文支持 -->
    <script type="text/javascript" src="/static/topjui/js/locale/topjui.lang.zh_CN.js"></script>
    <!-- layui框架js -->
    <script type="text/javascript" src="/static/plugins/layui/layui.js" charset="utf-8"></script>
</head>


</head>

<body>

<div data-toggle="topjui-layout" data-options="fit:true">
    <div data-options="region:'west',title:'字典集',split:true,border:false,width:'50%',iconCls:'fa fa-book',headerCls:'border_right',bodyCls:'border_right'">
        <!-- datagrid表格 -->
        <table data-toggle="topjui-edatagrid"
               data-options="id:'sDicCategoryDg',
                   reloadAfterSave:true,
                    url:'/sDicCategory/data',
                    saveUrl:'/sDicCategory/save?flag=add',
                    updateUrl:'/sDicCategory/save?flag=edit',
                    destroyUrl:'/sDicCategory/delete',
                    childGrid:{
                        param:'dicName:dicName',
                        grid:[
                            {type:'datagrid',id:'sDicDg'}
                        ]
                    }">
            <thead>
            <tr>
                <th data-options="field:'uuid',title:'UUID',checkbox:true"></th>
                <th data-options="field:'dicDesc',title:'字典集名称',sortable:true,editor:{type:'textbox',options:{required:true,height:30}}"></th>
                <th data-options="field:'dicName',title:'字典集代码',sortable:true,editor:{type:'textbox',options:{required:true,height:30}}"></th>
                <th data-options="field:'moduleText',title:'模块名称',sortable:true"></th>
                <th data-options="field:'module',title:'模块代码',width:150,sortable:true,editor:{type:'combobox',options:{height:30,panelHeight:200,
                    url:'/sDic/dics?dicName=ZB_SYS_MODULE'}}"></th>
            </tr>
            </thead>
        </table>
    </div>
    <div data-options="region:'center',iconCls:'fa fa-book',title:'字典项',split:true,border:false,bodyCls:'border_left'">
        <!-- datagrid表格 -->
        <table data-toggle="topjui-edatagrid"
               data-options="id:'sDicDg',
                    idField:'uuid',
                    reloadAfterSave:true,
                    selectOnCheck:true,
			        checkOnSelect:true,
			        reloadAfterSave:true,
                    url:'/sDic/data',
                    saveUrl:'/sDic/save?flag=add',
                    updateUrl:'/sDic/save?flag=edit',
                    destroyUrl:'/sDic/delete'">
            <thead>
            <tr>
                <th data-options="field:'id',title:'UUID',checkbox:true"></th>
                <th data-options="field:'uuid',title:'主键',sortable:true,hidden:true"></th>
                <th data-options="field:'dicName',title:'字典名称',width:200,sortable:true,editor:{type:'textbox',options:{required:true,height:30}}"></th>
                <th data-options="field:'dicDesc',title:'字典描述',width:100,sortable:true,editor:{type:'textbox',options:{required:true,height:30}}"></th>
                <th data-options="field:'keyCde',title:'代码',width:100,sortable:true,editor:{type:'textbox',options:{required:true,height:30}}"></th>
                <th data-options="field:'keyDesc',title:'代码描述',width:100,sortable:true,editor:{type:'textbox',options:{required:true,height:30}}"></th>
                <th data-options="field:'dicStsText',title:'状态',width:100,sortable:true"></th>
                <th data-options="field:'dicSts',title:'状态代码',width:100,sortable:true,editor:{type:'combobox',options:{required:true,height:30,panelHeight:74,
                    data: [{
                        text: '有效',
                        value: 'A'
                    },{
                        text: '无效',
                        value: 'I'
                    }]}}"></th>
                <th data-options="field:'updateUser',title:'更新人',sortable:true,editor:{type:'textbox',options:{height:30}},hidden:true"></th>
                <th data-options="field:'updateTime',title:'更新时间',sortable:true,editor:{type:'numberbox',options:{height:30}},hidden:true"></th>
            </tr>
            </thead>
        </table>
    </div>
</div>

<!-- 字典集 表格工具栏 -->
<div id="sDicCategoryDg-toolbar" class="topjui-toolbar" data-options="
       grid:{
           type:'edatagrid',
           id:'sDicCategoryDg'
       }" style="display:none">

    <a href="javascript:void(0)"
       data-toggle="topjui-menubutton"
       data-options="method:'edatagrid',
           extend:'#sDicCategoryDg-toolbar',
           btnCls:'topjui-btn-green',
           type:'addRow',
           iconCls:'fa fa-plus'">新增</a>

    <a href="javascript:void(0)"
       data-toggle="topjui-menubutton"
       data-options="method:'edatagrid',
       extend:'#sDicCategoryDg-toolbar',
       btnCls:'topjui-btn-blue',
       type:'saveRow',
       iconCls:'fa fa-save'">保存</a>

    <a href="javascript:void(0)"
       data-toggle="topjui-menubutton"
       data-options="method:'edatagrid',
       extend:'#sDicCategoryDg-toolbar',
       btnCls:'topjui-btn-black',
       type:'cancelRow',
       iconCls:'fa fa-close'">取消</a>

    <a href="javascript:void(0)"
       data-toggle="topjui-menubutton"
       data-options="method:'doAjax',
           extend:'#sDicCategoryDg-toolbar',
           btnCls:'topjui-btn-red',
           iconCls:'fa fa-trash',
           confirmMsg:'删除字典集会级联删除相关字典，这会导致系统不稳定，是否确定删除勾选内容？',
           grid: {
                uncheckedMsg:'请先勾选要删除的数据',
                param:'dicName:dicName',
                updateRow:false
              },
           onClick:deleteSDicCategory">删除</a>
    <a href="javascript:void(0)"
       data-toggle="topjui-menubutton"
       data-options="btnCls:'topjui-btn-orange',
       iconCls:'fa fa-recycle',
       onClick:reloadDicCache">重载数据字典缓存</a>
    <!--<a href="javascript:void(0)"
       data-toggle="topjui-menubutton"
       data-options="method:'doAjax',
           extend:'#sDicCategoryDg-toolbar',
           btnCls:'topjui-btn-red',
           iconCls:'fa fa-trash',
           confirmMsg:'删除字典集会级联删除相关字典，这会导致系统不稳定，是否确定删除勾选内容？',
           grid: {
                uncheckedMsg:'请先勾选要删除的数据',
                param:'dicName:dicName',
                updateRow:false
              },
           url:'/sDicCategory/delete'">删除</a>-->
</div>
<!-- 字典项 表格工具栏 -->
<div id="sDicDg-toolbar" class="topjui-toolbar" data-options="
       grid:{
           type:'edatagrid',
           id:'sDicDg'
       },parentGrid:{
           type:'datagrid',
           id:'sDicCategoryDg'
       }" style="display:none">
    <a href="javascript:void(0)"
       data-toggle="topjui-menubutton"
       data-options="method:'edatagrid',
           extend:'#sDicDg-toolbar',
           btnCls:'topjui-btn-green',
           type:'addRow',
           iconCls:'fa fa-plus'">新增</a>
    <a href="javascript:void(0)"
       data-toggle="topjui-menubutton"
       data-options="method:'edatagrid',
       extend:'#sDicDg-toolbar',
       btnCls:'topjui-btn-blue',
       type:'saveRow',
       iconCls:'fa fa-save'">保存</a>
    <a href="javascript:void(0)"
       data-toggle="topjui-menubutton"
       data-options="method:'edatagrid',
       extend:'#sDicDg-toolbar',
       btnCls:'topjui-btn-black',
       type:'cancelRow',
       iconCls:'fa fa-close'">取消</a>
    <a href="javascript:void(0)"
       data-toggle="topjui-menubutton"
       data-options="method:'edatagrid',
           extend:'#sDicDg-toolbar',
           btnCls:'topjui-btn-red',
           type:'destroyRow',
           iconCls:'fa fa-trash'">删除</a>
</div>

<script>
    function deleteSDicCategory() {
        var rows = $('#sDicCategoryDg').iDatagrid('getChecked');  //getChecked 在复选框被选中的时候返回所有行。
        if (rows.length == 0) {
            return $.iMessager.alert('操作提示', '请先勾选要删除的数据！', 'messager-error'); // 未勾选的话弹出消息窗口
        }
        $.iMessager.confirm('确认提示', '删除字典会导致系统不稳定，是否确定删除勾选内容？', function (r) {
            if (r) {
                $.each(rows, function (i) {
                    var dicName = rows[i].dicName;
                    var url = '/sDicCategory/delete';
                    var postData = {dicName: dicName}; // 请求中携带的JSON数据
                    $.post(url, postData, function (res) {
                        if (res.statusCode == 200) { // 后台返回状态值
                            $.iMessager.show({title: '操作提示', msg: res.message, timeout: 5000, showType: 'slide'});// '消息窗口'组件
                        } else {
                            $.iMessager.show({title: '操作提示', msg: res.message, timeout: 5000, showType: 'slide'});// '消息窗口'组件
                        }
                    }, 'JSON')
                });
                window.location.reload();
                /* $("#sDicDg").iDatagrid('reload');//请求成功后刷新表格
                $("#sDicCategoryDg").iDatagrid('reload');//请求成功后刷新表格*/
            }
        });
    }

    // 重载缓存
    function reloadDicCache() {
        // 提示信息
        $.iMessager.confirm('确认提示', '是否确定重载数据字典缓存？', function (r) {
            if (r) {

                var url = '/sDic/reload';
                $.post(url, function (res) {
                    if (res.statusCode == 200) { // 后台返回状态值
                        $.iMessager.show({title: '操作提示', msg: res.message, timeout: 5000, showType: 'slide'});// '消息窗口'组件
                    } else {
                        $.iMessager.show({title: '操作提示', msg: res.message, timeout: 5000, showType: 'slide'});// '消息窗口'组件
                    }
                }, 'JSON')
            }
        });
    }
</script>
</body>
</html>
